﻿using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Text;
using EuroManager.Domain.Simulator.Engine;

namespace EuroManager.Domain.Simulator.Helpers
{
    public static class Maths
    {
        public const float Epsilon = 1e-5f;

        public static float Pi
        {
            get { return (float)Math.PI; }
        }

        public static float Abs(float x)
        {
            return Math.Abs(x);
        }

        public static float Acos(float x)
        {
            return (float)Math.Acos(x);
        }

        public static float Cos(float angle)
        {
            return (float)Math.Cos(angle);
        }

        public static bool Equals(float x, float y, float delta = Epsilon)
        {
            return Abs(x - y) <= delta * Max(1, Abs(x) + Abs(y));
        }

        public static float Max(float x, float y)
        {
            return Math.Max(x, y);
        }

        public static float Min(float x, float y)
        {
            return Math.Min(x, y);
        }

        public static float MinMax(float min, float x, float max)
        {
            return Max(min, Min(x, max));
        }

        [Pure]
        public static int Sign(float x)
        {
            return Math.Sign(x);
        }

        public static float Sin(float angle)
        {
            return (float)Math.Sin(angle);
        }

        public static float Sqrt(float x)
        {
            return (float)Math.Sqrt(x);
        }
    }
}
